package com.by.config;

import com.baomidou.mybatisplus.annotation.DbType;
import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor;
import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author ServivE
 * @version 0.1
 * @className MybatisPlusConfig
 * @description
 * @date 2024/12/7 14:54
 * @since jdk17
 */

/**
 * 每个业务模块都需要分页，将MybatisPlus分页插件抽取出来存放到公共业务模块里。
 */
@Configuration
@MapperScan(basePackages = "com.by.mapper")
public class MybatisPlusConfig {

    /**
     * 添加分页插件
     */

    @Bean
    public MybatisPlusInterceptor mybatisPlusInterceptor() {
        MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor();
        interceptor.addInnerInterceptor(new PaginationInnerInterceptor(DbType.MYSQL));//如果配置多个插件,切记分页最后添加
        return interceptor;
    }
}
